package display {
    import com.adobe.serialization.json.JSON;
    
    import flare.animate.Transitioner;
    import flare.animate.Tween;
    import flare.display.TextSprite;
    
    import flash.events.KeyboardEvent;
    import flash.events.MouseEvent;
    import flash.filters.DropShadowFilter;
    import flash.text.TextFormat;
    import flash.ui.Keyboard;

    public class ActivityDetailSprite extends TextSprite {
        protected var _t:Tween;
        public static const DURATION:Number = 0.3;
        public function ActivityDetailSprite() {
            var fmt:TextFormat = new TextFormat("Arial", 14);
//            new TextFormat
            fmt.leftMargin = 2;
            fmt.rightMargin = 2;

            super(null, fmt, TextSprite.DEVICE);
            alpha = 0;
            visible = false;
            textField.border = true;
            textField.borderColor = 0;
            textField.background = true;
            textField.backgroundColor = 0xf5f5cc;
            textField.multiline = true;
            filters = [new DropShadowFilter(4,45,0,0.5)];
//            this.x = 500;
//            this.y = 0;
            
//            this.addEventListener(KeyboardEvent.KEY_UP, onClose);
//            this.addEventListener(MouseEvent.DOUBLE_CLICK, function(event:MouseEvent):void {
//               trace('onMouseClick >'); 
//            });
        }
        protected function onClose(event:KeyboardEvent):void {

        }
        public function close():void {
            this.alpha = 0;
            this.visible = false;
            return;
            if (_t && _t.running) _t.stop();
            _t = new Tween(this, DURATION, {alpha: 0, visible: false}, true);
            _t.play();
        }
        public function show():void {
            this.alpha = 1;
            this.visible = true;
            if (_t && _t.running) _t.stop();
            _t = new Tween(this, DURATION, {alpha:1, visible:true});
            _t.play();
        }
        public function update(data:Object):void {
            
            var list:String = '';
            for each (var d:Object in data.list) {
                list += '<li>' + d.type + ':   ';
                list += '<a target="_blank" href="' + d.url + '">' + '<u>' + d.anchor + '</u>' + '</a>';
                list += '</li>';
            }
            trace(JSON.encode(data));
            var html:String = '<font size="10" />' + list;
//            var html:String = data.name + '<img src="resources/assets/Jason.png" width="16" height="16" />';
//            var html:String = '<font size="10" />' + data.name + ' <br><font face="Utopia" size="18" /> There <img src="' + data.picture + '" width="16" height="16" />';
            textField.htmlText = html;
//            textField.ht
            dirty();
//            textField.text = html;
            trace(html);
//            trace(alpha + ' ' + visible);
//            trace(textField.text);
            trace(textField.htmlText);
//            textField.text = html;
            
//            textField.ht
        }
    }
}
